<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="<%= MapperPackageName %>.<%= camelCaseName(tableName, true) %>Mapper">

    <select id="queryMapByPage" resultType="<%= utilsPackageName %>.CamelMap">
        SELECT
        t.*
        FROM
        <%= tableName %> t
    </select>

    <!--批量插入 <%= camelCaseName(tableName, true) %>-->
    <insert id="batchInsert" parameterType="java.util.List" >
        insert into <%= tableName %>
        (<% table.columns.forEach(function(item){ %><%= item.name %><% if(item.name != table.columns[table.columns.length - 1].name) { %>,<% } %><% }); %>)
        values
        <foreach item="item" index="index" collection="<%= camelCaseName(tableName, false) %>List" separator=",">
            (<% table.columns.forEach(function(item){ %>#{item.<%= camelCaseName(item.name) %>}<% if(item.name != table.columns[table.columns.length - 1].name) { %>,<% } %>
            <% }); %>)
        </foreach>
    </insert>

    <!--批量更新 <%= camelCaseName(tableName, true) %>-->
    <update  id="batchUpdate" parameterType="java.util.List" >
        <!-- 接收list参数，循环着组装sql语句，注意for循环的写法
            separator=";" 代表着每次循环完，在sql后面放一个分号
            item="item" 循环List的每条的结果集
            collection="list" list 即为 map传过来的参数key -->
        <foreach collection="<%= camelCaseName(tableName, false) %>List" separator=";" item="item">
            update <%= tableName %> set
            <% table.columns.forEach(function(item){ %><% if(!item.primaryKey) { -%><%= item.name %> = #{item.<%= camelCaseName(item.name) %>}<% if(item.name != table.columns[table.columns.length - 1].name) { %>,<% } %><% } %>
            <% }); %>
            <where>
                <% table.columns.forEach(function(item){ %><% if(item.primaryKey) { -%>AND <%= item.name %> = #{item.<%= camelCaseName(item.name) %>}<% } %><% }); _%>

            </where>
        </foreach>
    </update>

</mapper>